<template>
	<view>
		<nav-com :typeList="typeList" v-on:pChangeType="changeType" :toplistcat="toplistcat" :typeIndex="typeIndex" :flagtag="flagtag" ></nav-com>
	</view>
</template>

<script>
	import {politics,politicsList} from '../../api/advisory.js'
	import navicom from '@/pages/index/Navi-com.vue'
	export default {
		components: {
			'NavCom':navicom
		},
		data(){
			return{
				typeList:[],
				//当前默认选项
				typeIndex:0,
				//选项卡内容
				toplistcat:[],
				flagtag:true
			}
		},
		onLoad(){
			this.tablist()
		},
		methods:{
			async tablist(){
				console.log("dd")
				const {data : res} = await  politics()
				this.typeList =res
				this.changeType({id:1})
			},
			async changeType(val){
				const res = await politicsList(val.id)
				if(res.code == 1){
					this.flagtag = res.data.length==0?true:false;
					this.typeIndex = this.typeList.findIndex(el => el.id  == val.id)
					this.toplistcat = res.data
				}
				
			},
		}
		
	}
</script>

<style scoped lang="scss">
</style>